package com.example.controller.teacher;

import com.example.common.Result;
import com.example.entity.DTO.StudentCourseDetailDTO;
import com.example.entity.StudentCourse;
import com.example.service.teacher.GradeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/teacher")
public class GradeController {
    @Resource
    private GradeService gradeService;

    /**
     * 获取所有有关学生选课信息
     */
    @GetMapping("/selectAllGrade")
    public Result selectAllGrade(@RequestParam(defaultValue = "") String courseName,
                               @RequestParam(defaultValue = "") String studentName,
                               @RequestParam(defaultValue = "") Integer teacherId) {
        List<StudentCourseDetailDTO> grades = gradeService.selectAllGrade(courseName, studentName, teacherId);
        return Result.success(grades);
    }

    /**
     * 教师给学生评分
     */
    @PostMapping("/updateGrade")
    public Result updateGrade(@RequestBody StudentCourse studentCourse) {
        gradeService.updateGrade(studentCourse);
        return Result.success();
    }

}
